<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class setting extends CI_Controller {

	function setting()
	{
		parent::__construct();
		$this->load->library('session');
		$this->load->model('admin_model','admin');
		$this->load->helper('functions');

	}

	//网站设置
	public function index()
	{
		if($_SERVER['REQUEST_METHOD']=='POST')
		{
			$r = '';
			$data = $this->input->post();
			//print_r($data);exit;
			$re = $this->admin->check_data('siteinfo',$data);
			if($re==1)
			{
				$r = $this->admin->update('siteinfo',$data,array('SiteName'=>$data['SiteName']));
			}
			elseif($re==2)
			{
				$r = $this->admin->add('siteinfo',$data);
			}

			if($r)
			{
				echo '保存成功';
			}
			else
			{
				echo '保存失败';
			}
		}
		else
		{
			$result = $this->admin->get('siteinfo');
			$this->load->view('admin/seting_tpl',array('data'=>$result,'actionurl'=>'index.php?c=setting'));
		}
	}

	//管理员修改
	public function AdminEdit()
	{
		if($_SERVER['REQUEST_METHOD']=='POST')
		{
			$r = '';
			$data = $this->input->post();
			//print_r($data);exit;
			$re = $this->admin->check_data('user',$data);
			if($re==1)
			{
				$r = $this->admin->update('user',$data,array('userid'=>$data['userid']));
			}
			elseif($re==2)
			{
				$r = $this->admin->add('user',$data);
			}

			if($r)
			{
				echo '保存成功';
			}
			else
			{
				echo '保存失败';
			}
		}
		else
		{
			$result = $this->admin->get('user');
			$this->load->view('admin/AdminEdit_tpl',array('data'=>$result,'actionurl'=>'index.php?c=setting&m=AdminEdit'));
		}
	}

	/*//邮箱设置
	public function EmailSeting()
	{
		if($_SERVER['REQUEST_METHOD']=='POST')
		{
			$r = '';
			$data = $this->input->post();
			//print_r($data);exit;
			$re = $this->admin->check_data('siteinfo',$data);
			if($re==1)
			{
				$r = $this->admin->update('siteinfo',$data,array('SmtpIP'=>$data['SmtpIP']));
			}
			elseif($re==2)
			{
				$r = $this->admin->add('siteinfo',$data);
			}

			if($r)
			{
				echo '保存成功';
			}
			else
			{
				echo '保存失败';
			}
		}
		else
		{
			$result = $this->admin->get('siteinfo');
			$this->load->view('admin/EmailSeting_tpl',array('data'=>$result,'actionurl'=>'index.php?c=setting&m=EmailSeting'));
		}
	}

	//数据库设置
	public function DBSeting()
	{
		if($_SERVER['REQUEST_METHOD']=='POST')
		{

		}
		else
		{

			$this->load->view('admin/DBSeting_tpl');
		}
	}

	//联系方式
	public function LinkStyle()
	{
		if($_SERVER['REQUEST_METHOD']=='POST')
		{

		}
		else
		{

			$this->load->view('admin/LinkStyle_tpl');
		}
	}*/

}

/* End of file admin_ctrl.php */
/* Location: ./application/controllers/admin_ctrl.php */